﻿/// <reference path="jquery-1.6.1-vsdoc.js" />

$(function () {
    $(".button").button();
    // Accordion
    $(".accordion").accordion({
        header: "h3",
        navigation: true
    });

    $(".autocomplete").autocomplete({
        source: function (request, response) {
            $.ajax({
                url: "/WebService/AutoComplete.asmx/" + $('.autocomplete').attr('FunctionName'),
                data: "{ 'prefixText': '" + request.term + "' }",
                dataType: "json",
                type: "POST",
                contentType: "application/json; charset=utf-8",
                dataFilter: function (data) { return data; },
                success: function (data) {
                    response($.map(data.d, function (item) {
                        return {
                            value: item
                        }
                    }))
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    alert(textStatus);
                }
            });
        },
        minLength: 2
    });
});